﻿namespace HuaWei
{
    using System;
    using System.IO;
    using System.IO.Compression;

    public static class ZipHelp
    {
        public static string CompressFile(string path)
        {
            FileStream stream = File.OpenRead(path);
            FileStream stream2 = File.Create(path + ".gz");
            byte[] buffer = new byte[stream.Length];
            stream.Read(buffer, 0, buffer.Length);
            using (GZipStream stream3 = new GZipStream(stream2, CompressionMode.Compress))
            {
                stream3.Write(buffer, 0, buffer.Length);
            }
            stream.Close();
            stream2.Close();
            return (path + ".gz");
        }

        public static string UncompressFile(string path)
        {
            FileStream stream = File.OpenRead(path);
            FileStream stream2 = File.Create(path);
            byte[] buffer = new byte[0x1000];
            using (GZipStream stream3 = new GZipStream(stream, CompressionMode.Decompress, false))
            {
                int count = stream3.Read(buffer, 0, buffer.Length);
                stream2.Write(buffer, 0, count);
            }
            stream.Close();
            stream2.Close();
            return (path + ".xml");
        }
    }
}

